package com.zqq.user.service.impl

import com.zqq.baselibrary.ext.convert
import com.zqq.baselibrary.ext.convertBoolean
import com.zqq.baselibrary.http.rx.BaseException
import com.zqq.baselibrary.http.rx.BaseFuncBoolean
import com.zqq.baselibrary.http.rx.BaseResp
import com.zqq.user.service.UserService
import com.zqq.user.service.bean.UserInfo
import com.zqq.user.service.respository.UserRepository
import rx.Observable
import rx.functions.Func1
import javax.inject.Inject

/**
 * 用户模块业务实现类
 * wc
 * @author zqq on 2018/7/26
 */
class UserServiceImpl @Inject constructor() : UserService {

    @Inject
    lateinit var repository: UserRepository

    //1.用户注册
    override fun register(mobile: String, pwd: String, verifyCode: String): Observable<Boolean> {
        return repository.register(mobile, pwd, verifyCode)
                .convertBoolean()
    }

    //2.登录
    override fun login(mobile: String, pwd: String, pushId: String): Observable<UserInfo> {
        return repository.login(mobile, pwd, pushId)
                .convert()
    }

    //3. 修改用户资料
    override fun editUser(userIcon: String, userName: String, userGender: String, userSign: String): Observable<UserInfo> {
        return repository.editUser(userIcon, userName, userGender, userSign)
                .convert()
    }

    //忘记密码
    override fun forgetPwd(mobile: String, verifyCode: String): Observable<Boolean> {
        return repository.forgetPwd(mobile, verifyCode)
                .convertBoolean()
    }

    //重置密码
    override fun resetPwd(mobile: String, pwd: String): Observable<Boolean> {
        return repository.resetPwd(mobile, pwd)
                .convertBoolean()
    }

}